﻿using System;
namespace Q1
{
	public class question2
	{
		public question2()
		{
            Console.Write("请输入数组长度：");
            int length = int.Parse(Console.ReadLine());

            int[] nums = new int[length];

            Console.WriteLine("请依次输入数组元素：");
            for (int i = 0; i < length; i++)
            {
                Console.Write($"元素{i + 1}: ");
                nums[i] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine();

            int max = nums[0];
            int min = nums[0];
            int sum = 0;

            foreach (int num in nums)
            {
                if (num > max)
                {
                    max = num;
                }

                if (num < min)
                {
                    min = num;
                }

                sum += num;
            }

            double avg = (double)sum / nums.Length;

            Console.WriteLine("最大值: {0}", max);
            Console.WriteLine("最小值: {0}", min);
            Console.WriteLine("平均值: {0}", avg);
            Console.WriteLine("值总和: {0}", sum);
        }
	}
}

